<?php

//	Author: 	Christos Polydorou
//	Email:		std04237@di.uoa.gr
//	Purpose: 	Delete a category for a user

require_once ("../DB/connection.php");
require_once ("../DB/defines.php");
require_once ("../Frameworks/Objects/user.php");

function DB_user_getuser(&$user)
{

    global $conn;

    // The name of the stored procedure
    $sp_name = "usp_user_getuser";

    // The return variable
    $retval;

    // Get the values
    $username = $user->GetUsername();

    // Create a new statement
    $stmt = mssql_init($sp_name, $conn);

    // Bind values
    mssql_bind($stmt, "RETVAL", $retval, SQLINT4, true, false, 1);
    mssql_bind($stmt, '@username', $username, SQLVARCHAR, false, false, 50);

    // Execute the statement
    $status = mssql_execute($stmt);
    if (!$status)
        return DB_ERROR_GENERAL;
    else
    {
        $row = mssql_fetch_row($status);
        //			&$user->SetId($row[0]);
        $user->SetEmail($row[1]);
        //			&$user->SetDateCreated($row[2]);
        $user->SetUserType($row[3]);
        $user->SetName($row[4]);
        $user->SetSurName($row[5]);
        return DB_OK;
    }
}

?>